#include "../extincludes/cpGUI.h"
#include <vector>
#include <SFML/Graphics.hpp>

using namespace std;

int main()
{
	sf::RenderWindow App(sf::VideoMode(800,600,32), "cpGUI");
	App.SetPosition(10,10);

	cp::cpGuiContainer myGUI;
   vector<cp::cpTextInputBox*> iB;
   for(int i = 0 ; i < 4 ; i++)
   {
      cp::cpTextInputBox *a = new cp::cpTextInputBox(&App, &myGUI, "", 500, 400+30*i, 230, 35);
      iB.push_back(a);
   }

	const sf::Input& input = App.GetInput();

	while(App.IsOpened())
	{

		sf::Event Event;
		while(App.GetEvent(Event))
		{
			if(Event.Type == sf::Event::Closed)
				App.Close();
			if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
				App.Close();
         
         for(int i = 0 ; i < iB.size() ; i++)
            iB[i]->ProcessTextInput(&Event);
			myGUI.ProcessKeys(&Event);
		}

      for(int i = 0 ; i < iB.size() ; i++)
      {
         std::string name;
         if(iB[i]->CheckState(&input) == cp::CP_ST_MOUSE_LBUTTON_RELEASED)
            name = iB[i]->GetLabelText();
      }
		App.Clear(sf::Color(180,180,180));
      for(int i = 0 ; i < iB.size() ; i++)
         iB[i]->Draw();
		App.Display();
	}
	return EXIT_SUCCESS;
}


